﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using EHTSaleManager.Code.BLL;
using EHTSaleManager.Code.Entity;
using EHTSaleManager.Code.Utility;

namespace EHTSaleManager.UIAdmin
{
    public partial class AdminDocumentComfirmDelete : System.Web.UI.Page
    {
        public Int32 DocumentID = -1;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["DocumentID"] != null)
            {
                try
                {
                    DocumentID = Int32.Parse(Request.QueryString["DocumentID"].ToString());
                }
                catch (Exception ex)
                {
                    DocumentID = -1;
                }
            }

            if (DocumentID != -1)
            {
                ViewState["action"] = HangSo.ACTION_ADD;
                Document theDocument = DocumentProvider.GetDocumentByDocumentID(DocumentID);
                this.ltrMessage.Text = "Er du sikker sletter Document : " + theDocument.Description;
                ViewState["ID"] = theDocument.DocumentID;
            }
        }

        protected void btnDelete_Click(object sender, EventArgs e)
        {
            if (ViewState["ID"] != null)
            {
                DocumentID = Int32.Parse(ViewState["ID"].ToString());
                DocumentProvider.DeleteDocumentByDocumentID(DocumentID);
            }

            Response.Redirect("AdminDocuments.aspx");
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            Response.Redirect("AdminDocuments.aspx");
        }
    }
}